package com.thf.controller;


import com.thf.model.ResultData;
import com.thf.service.ProductService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Map;

@RestController
public class ProductController {
    @Resource
    private ProductService productService;

    @RequestMapping("/productFindAll")
    public ResultData productFindAll(Integer startPage,Integer pageSize,@RequestBody Map map){
        return productService.productFindAll(startPage,pageSize,map);
    }
    @RequestMapping("/getCount")
    public Integer getCount(@RequestBody Map map){
        Integer count = productService.getCount(map);
        return count;
    }
    @RequestMapping("/add")
    public ResultData add(@RequestBody Map map){
        return productService.add(map);
    }
    @RequestMapping("/getProductById")
    public ResultData getProductById( Integer stringToInt){
        return productService.getProductById(stringToInt);
    }
    @RequestMapping("/update")
    public ResultData update(@RequestBody Map map){
        return productService.update(map);
    }
    @RequestMapping("/delete")
    public ResultData delete(Integer stringToInt){
        return productService.delete(stringToInt);
    }
//    public String defaultFallback(){
//        return "默认提示：对不起，网络太拥挤了！";
//    }
}
